package com.meilingcloud.research.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.meilingcloud.research.domain.RwsQualityEntry;
import com.meilingcloud.research.mapper.RwsQualityEntryMapper;
import com.meilingcloud.research.service.IRwsQualityEntryService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 质控条目 Service业务层处理
 *
 * @author chenl
 * @date 2021-05-10
 */
@Service
public class RwsQualityEntryServiceImpl extends ServiceImpl<RwsQualityEntryMapper, RwsQualityEntry> implements IRwsQualityEntryService {

    @Override
    public List<RwsQualityEntry> queryList(RwsQualityEntry rwsQualityEntry) {
        LambdaQueryWrapper<RwsQualityEntry> lqw = Wrappers.lambdaQuery();
        if (StringUtils.isNotBlank(rwsQualityEntry.getQcEntryName())) {
            lqw.like(RwsQualityEntry::getQcEntryName, rwsQualityEntry.getQcEntryName());
        }
        if (StringUtils.isNotBlank(rwsQualityEntry.getQcEntryType())) {
            lqw.eq(RwsQualityEntry::getQcEntryType, rwsQualityEntry.getQcEntryType());
        }
        if (rwsQualityEntry.getQcEntryExpectMin() != null) {
            lqw.eq(RwsQualityEntry::getQcEntryExpectMin, rwsQualityEntry.getQcEntryExpectMin());
        }
        if (rwsQualityEntry.getQcEntryExpectMax() != null) {
            lqw.eq(RwsQualityEntry::getQcEntryExpectMax, rwsQualityEntry.getQcEntryExpectMax());
        }
        if (StringUtils.isNotBlank(rwsQualityEntry.getQcEntryUnit())) {
            lqw.eq(RwsQualityEntry::getQcEntryUnit, rwsQualityEntry.getQcEntryUnit());
        }
        return this.list(lqw);
    }
}
